package com.tongjie.hotelbooking.security.authentication;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.io.Serializable;
import java.util.Collection;

public class UserAuthentication extends UsernamePasswordAuthenticationToken implements Serializable {

    private static final long serialVersionUID = 5241937039825439901L;

    private Object principal;
    private Object credentials;

    public UserAuthentication(Object principal, Object credentials) {
        super(null, null);
        this.principal = principal;
        this.credentials = credentials;
        setAuthenticated(false);
    }

    public UserAuthentication(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
        super(null, null);
        this.principal = principal;
        this.credentials = credentials;
        super.setAuthenticated(true); // must use super, as we override
    }


    @Override
    public Object getPrincipal() {
        return principal;
    }

    @Override
    public Object getCredentials() {
        return credentials;
    }

}
